#ifndef __WS2811_H
#define __WS2811_H

#include "dma.h"
#include "tim.h"

#define WS2811S 20  //WS2811的芯片个数，一个WS2811接3个LED，LED总个数=3*WS2811的芯片个数
#define LEDS 3*WS2811S  //LED个数

#define WS2811_DATA_FRAME_LEN 24     //每个WS2811芯片数据帧数长度
#define WS2811_RESET_FRAME_LEN 72     //WS2811复位帧长度
#define HIGH_PULSE 72   //'1' 对应的PWM占空比
#define LOW_PULSE 18    //'0' 对应的PWM占空比
#define RESET_PULSE 0   //'RES' 对应的PWM占空比 

static uint16_t RGB_Test[WS2811_DATA_FRAME_LEN+WS2811_RESET_FRAME_LEN]={
    18,18,18,18,18,18,18,18,
    72,72,72,72,72,72,72,72,
    18,18,18,18,18,18,18,18,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
};
static uint16_t RGB_Testdata[3][WS2811_DATA_FRAME_LEN+WS2811_RESET_FRAME_LEN]={
  {
    18,18,18,18,18,18,18,18,
    72,72,72,72,72,72,72,72,
    18,18,18,18,18,18,18,18,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
  },//R
	{
    18,18,18,18,18,18,18,18,
    18,18,18,18,18,18,18,18,
    72,72,72,72,72,72,72,72,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
  },//G
  {
    72,72,72,72,72,72,72,72,
    18,18,18,18,18,18,18,18,
    18,18,18,18,18,18,18,18,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
  },//B
};

static uint32_t RGB_Fountain_Data[20]={
    0xFF0000,
    0xfb3131,
    0xe77300,
    0xFF7F00,
    0xff9225,
    0xf2f202,
    0xFFFF00,
    0xffff3e,
    0x3bfe3b,
    0x00FF00,
    0x00c600,
    0x5dfcfc,
    0x00FFFF,
    0x00c6c6,
    0x6b6bfd,
    0x0000FF,
    0x0303c5,
    0xa53cfc,
    0x8B00FF,
    0x5f04ab,
};

void ws2811_Test(void);
void ws2811_Rgb_Singleset(uint32_t RGB, uint32_t LEDn);
void ws2811_Fountain(uint32_t LEDn);

#endif
